<%@ page language="java"
		 import="com.ruohi.manage.DBType,com.ruohi.manage.JobExecute,com.ruohi.manage.PoolManager,com.ruohi.util.common.Common,com.ruohi.util.common.CommonString"
		 pageEncoding="UTF-8" %>
<%@ page import="com.ruohi.util.dbutil.DBHelper" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.Arrays" %>
<%@ page import="java.util.LinkedHashMap" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%
	String event = CommonString.getFormatPara(request.getParameter("eventAfter"));
	String [] eventArr = event.split(",");
	List<String> eventList =Arrays.asList(eventArr);
	DBHelper dbHelper = DBHelper.getInstance();
	Connection connection = null;  
	Map model = null;
	try{
		//更新调度信息
		if(eventList.contains("scheduler")){  
			JobExecute jobExecute = new JobExecute();
			jobExecute.shutdown();  
			jobExecute.start(); 
		}    
		//更新标签变量
		if(eventList.contains("updateStaticVariable")){
			
		}
		//商品网类别更新appication
		if(eventList.contains("updAppCategoryGift")){
			Common.doPostHttpAsync ( "http://www.52sdskj.com/tools/application/update_application.jsp?target=category", null, null );
		}
		//商品网品牌更新appication
		if(eventList.contains("updAppBrandGift")){
			Common.doPostHttpAsync ( "http://www.52sdskj.com/tools/application/update_application.jsp?target=brand", null, null );
		}  
		//商品网供应商更新appication
		if(eventList.contains("updAppSupplierGift")){
			Common.doPostHttpAsync ( "http://www.52sdskj.com/tools/application/update_application.jsp?target=supplier", null, null );
		}
		//商品网过滤关键词更新application
		if(eventList.contains("updAppFilterKeywords")){
			Common.doPostHttpAsync ( "http://www.52sdskj.com/tools/application/update_application.jsp?target=keywords", null, null );
			//Common.doPostHttpAsync("http://member.21-sun.com/tools/update_filter_keyword_application.jsp", null, null);
			//Common.doPostHttpAsync("http://member.21-sun.com/home/tools/application/update_part_application.jsp?target=keywords", null, null);
		}
		//商品网快递运费更新application
		if(eventList.contains("updAppExpressCost")){
			Common.doPostHttpAsync ( "http://www.52sdskj.com/tools/application/update_application.jsp?target=express", null, null );
		}
		//商品网枚举更新application
		if(eventList.contains("updAppEnum")){
			Common.doPostHttpAsync ( "http://www.52sdskj.com/tools/application/update_application.jsp?target=enum", null );
		}
		//删除套餐产品后删除对应的子产品
		if(eventList.contains("deletePackageProduct")){
			connection = PoolManager.getConnection(DBType.BUSINESS);
			String del_no = CommonString.getFormatPara(request.getParameter("del_no"));
			dbHelper.execute("delete from gift_product_package_product where package_product_no in (" + del_no + ")", connection);
		}
		//删除订单后删除订单中的产品
		if(eventList.contains("deleteOrderProduct")){
			connection = PoolManager.getConnection(DBType.BUSINESS);
			String del_order_no = CommonString.getFormatPara(request.getParameter("del_order_no"));
			dbHelper.execute("delete from gift_order_product where order_num in (" + del_order_no + ")", connection);
		}
		
		//配件网品牌更新application
		if(eventList.contains("updAppBrandPart")){
			//TODO:配件网前台更新application页面
		}
		//配件网类别更新application
		if(eventList.contains("updAppCategoryPart")){
			//TODO:配件网前台更新application页面
		}
		
		//生成全部配件索引
		if(eventList.contains("generate_all_part_index")){
			//Common.doPostHttpAsync("http://part.21-sun.com/tools/solr/generate_all_part_index.jsp", null);
		}
		//生成配件索引
		if(eventList.contains("generate_part_index")){
			String part_id = CommonString.getFormatPara(request.getParameter("updateId")).equals("")?CommonString.getFormatPara(request.getParameter("keyId")):CommonString.getFormatPara(request.getParameter("updateId"));
			//Common.doPostHttpAsync("http://part.21-sun.com/tools/solr/generate_part_index.jsp?part_id=" + part_id, null);
		}
		//生成全部供应商索引
		if(eventList.contains("generate_all_dealer_index")){
			//Common.doPostHttpAsync("http://part.21-sun.com/tools/solr/generate_all_dealer_index.jsp", null);
		}
		//生成供应商索引
		if(eventList.contains("generate_dealer_index")){
			String dealer_id = CommonString.getFormatPara(request.getParameter("updateId")).equals("")?CommonString.getFormatPara(request.getParameter("keyId")):CommonString.getFormatPara(request.getParameter("updateId"));
			//Common.doPostHttpAsync("http://part.21-sun.com/tools/solr/generate_dealer_index.jsp?dealer_id=" + dealer_id, null);
		}
		//删除供应商索引
		if(eventList.contains("deleteDealerIndex")){
			String dealer_id = CommonString.getFormatPara(request.getParameter("updateId")).equals("")?CommonString.getFormatPara(request.getParameter("keyId")):CommonString.getFormatPara(request.getParameter("updateId"));
			//Common.doPostHttpAsync("http://part.21-sun.com/tools/solr/gdelete_dealer_index.jsp?dealer_id=" + dealer_id, null);
		}
		
		//add by gp--2014/11/12
		//更新产品枚举appication
		if(eventList.contains("updProductEnum")){
			LinkedHashMap enumMap = null;
		    List enumList = null;
			String sql = " select * from service_common_enum_product where is_show = 1 order by order_no desc,no asc ";
			connection = dbHelper.getConnection();
			enumList = dbHelper.getMapList(sql, connection);
			enumMap = new LinkedHashMap();
			Map info = null;
			for (int i = 0; i < enumList.size(); i++) {
				info = (Map)enumList.get(i);
				enumMap.put((String)info.get("no"), (String)info.get("name"));
			}
			application.setAttribute("enumProductMap", enumMap);
			application.setAttribute("enumProductList", enumList);
			
			//更新前台 
			Common.doPostHttpAsync ( "http://www.52sdskj.com/tools/application/update_application.jsp?target=enumProduct", null );
		}		
		
	}catch(Exception e){
		e.printStackTrace();
	}finally{
		DBHelper.freeConnection(connection);
	}
%>